/*
 * FTNANDC024 driver developed by Mychaela Falconia at CarrierComm, Inc.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along
 * with this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 */

#ifndef __FTNANDC024_PRIV_H__
#define __FTNANDC024_PRIV_H__

struct ftnandc024_data {
	struct mtd_info mtd;
	struct device *dev;
	void __iomem *io_base;
	uint8_t __iomem *data_sram;

	/* driver state */
	struct mutex mutex;
	int page_in_buffer;
	bool reset_needed;

	/* IRQ support */
	bool		use_irq;
	uint32_t	intr_status;
	wait_queue_head_t wq;

	/* data format */
	unsigned	pages_per_block;
	unsigned	sector_size;
	unsigned	sector_shift;
	unsigned	sectors_per_page;
	unsigned	subpage_mask;
	bool		smallpage_cmds;
	struct nand_ecclayout ecclayout;
};

#define to_ftnandc024_data(m) container_of(m, struct ftnandc024_data, mtd)

extern irqreturn_t ftnandc024_irq_handler(int irq, void *dev_id);
extern int ftnandc024_execute_command(struct ftnandc024_data *cntr,
					uint32_t command);
extern int ftnandc024_reset_nand_chip(struct ftnandc024_data *cntr);

extern int ftnandc024_mtd_read_method(struct mtd_info *mtd, loff_t from,
				      size_t len, size_t *retlen, u_char *buf);
extern int ftnandc024_mtd_readoob_method(struct mtd_info *mtd, loff_t from,
					 struct mtd_oob_ops *ops);
extern int ftnandc024_mtd_write_method(struct mtd_info *mtd, loff_t to,
					size_t len, size_t *retlen,
					const u_char *buf);
extern int ftnandc024_mtd_writeoob_method(struct mtd_info *mtd, loff_t to,
					  struct mtd_oob_ops *ops);
extern int ftnandc024_mtd_erase_method(struct mtd_info *mtd,
					struct erase_info *instr);

#endif
